package com.woniuxy.excepton;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;
@ControllerAdvice
public class GlobalException {
    @ExceptionHandler(value = Exception.class)
    public ModelAndView hanlderError(Exception ex){
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("ex",ex);
        modelAndView.setViewName("error");
        return modelAndView;
    }
}
